﻿<template>
    <el-col :sm="24" :md="pzoption.mdwidth"  v-show="ishide">
        <i class="iconfont icon-shezhi pull-right widgetset hidden-print" @click.stop="dialogInputVisible = true"></i>
        <i class="iconfont icon-shanchu pull-right widgetdel hidden-print" @click.stop="delWid(pzoption.wigdetcode)"></i>
        <el-form-item :label="pzoption.title" :prop="'wigetitems.' + index + '.value'" :rules="childpro.rules">
            <el-input :placeholder="childpro.placeholder" :readonly="childpro.readonly" v-model="pzoption.value"  v-if="isfb"  clearable>
            </el-input>
            <div class="disdiv" v-html="pzoption.value" v-if="!isfb"  >

            </div>
        </el-form-item>
        <el-dialog title="组件属性" :visible.sync="dialogInputVisible">
            <el-form-item label="前缀">
                <el-input v-model="childpro.snqz" autocomplete="off"></el-input>
            </el-form-item>
            <el-form :model="childpro">
                <el-form-item label="年月日部分">
                    <el-radio v-model="childpro.itemtype" label="yyyyMMdd">yyyyMMdd</el-radio>
                    <el-radio v-model="childpro.itemtype" label="yyyyMM">yyyyMM</el-radio>
                    <el-radio v-model="childpro.itemtype" label="yyyy">yyyy</el-radio>
                </el-form-item>
            </el-form>

            <el-form-item label="序号样式">
                <el-radio v-model="childpro.snlen" label="3">001</el-radio>
                <el-radio v-model="childpro.snlen" label="4">0001</el-radio>
                <el-radio v-model="childpro.snlen" label="5">00001</el-radio>
            </el-form-item>
        </el-dialog>
    </el-col>

</template>
<script>
    module.exports = {
        props: ['pzoption', 'index'],
        data: function () {
            return {
                dialogInputVisible: false,
                pdid: ComFunJS.getQueryString('pdid', '0'),
                childpro: {
                    placeholder: "",
                    readonly: true,
                    hide: false,
                    snqz: "",
                    itemtype: "yyyyMMdd",
                    snlen: "3",
                    rules: {
                        required: false, message: '不能为空', type: "string"
                    }
                }
            }
        },
        computed: {
            ishide() {
                return !this.childpro.hide || window.location.href.indexOf('FormBuildV1') > -1
            },
            isfb() {
                return  window.location.href.indexOf('FormBuildV1') > -1
            }
        },
        methods: {
            delWid: function (wigdetcode) {
                // 子组件中触发父组件方法ee并传值cc12345
                this.$root.nowwidget = {};
                _.remove(this.$root.FormData.wigetitems, function (obj) {
                    return obj.wigdetcode == wigdetcode;
                });
            }
        },
        mounted: function () {
            var pro = this;
            pro.$nextTick(function () {
                if (pro.$root.addchildwig) {
                    pro.$root.addchildwig();//不能缺少,dom加载完成
                }
                if (pro.pzoption.childpro.itemtype) {
                    pro.childpro = pro.pzoption.childpro
                } else {
                    pro.pzoption.childpro = pro.childpro;

                }
                if (pro.pdid!="0") {
                    $.getJSON("/api/Bll/ExeAction?Action=FORMBI_CRWFNUM", { P1: pro.pdid, P2: pro.childpro.itemtype, snqz: pro.childpro.snqz, snlen: pro.childpro.snlen }, function (result) {
                        if (!result.ErrorMsg) {
                            pro.pzoption.value = result.Result;
                           
                        }
                    })

                }
           
            })

        },
        watch: {
           
        }
    };
</script>